<?php
namespace Admin\Controller;
use Think\Controller;
class AduserController extends Controller {
    public $aduser;
    public function __construct() {
    	parent::__construct();
        $this->aduser = M('aduser');
    }

    public function aduser() {
       $arr = $this->aduser->field('id,username')->select();
       $this->assign('aduser',$arr);

       $this->display('aduser_list');
     }
   
   public function  add_admin() {
       $this->display();
   }

    public function addaduser() {
      
       if($_POST['username'] && $_POST['passwdF']) {
       	     $aduser = I('post.username');
       	     $pwd = I('post.passwdF');
       	     $cpwd = I('post.passwdS');
          if($pwd != $cpwd) {
             $this->error('两次输入密码不一致');
         }
             $this->aduser->username = $aduser;
             $this->aduser->pwd = $pwd;
             $a = $this->aduser->add();
        } 

            if ($a) {
                $this->success('添加管理员成功','add_admin');
            } else {
                $this->error('添加管理员失败，请重新填写完整','add_admin');
            }       
      }
}